<?php 
	/**
	* 
	*/
	class UserContentView
	{
		private $model;
		private $controller;
		function __construct($model,$controller)
		{
			$this->model=$model;
			$this->cotroller=$cotroller;
		}
		function display_header()
		{
			if(isset($_GET['user_name']))
			{
			 	$user_name=$_GET['user_name'];
				$user_id=$this->model->get_user_id_by_name($user_name);
				$user_meta=get_user_meta($user_id);
				$user_info=$this->model->get_user_info($user_id);
			}
			$banner_image=$this->model->get_user_image($user_id,8);
			$upload_dir = wp_upload_dir();
			?>
				<header class="user-profile active">
				    <div class="inner" style="width: 1060px;"><section id="profile-photo-banner"><figure class="banner-box single" style="left: 0px">
				    <div class="wrapper">
				            
				            <a href="<?php echo get_page_link(184).'' ?>">
				                <img style="<?php echo $this->model->get_style($banner_image[0]->image_url); ?>" class="back active loaded" src="<?php echo $upload_dir['baseurl'].'/photo-gallery'.$banner_image[0]->image_url; ?>">
				            </a>
				        
				    </div>
				</figure>
				<figure class="banner-box single" style="left: 272px">
				    <div class="wrapper">
				            
				            <a href="/i/hjI27apLj">
				                <img style="<?php echo $this->model->get_style($banner_image[1]->image_url);?>" class="back active loaded" src="<?php echo $upload_dir['baseurl'].'/photo-gallery'.$banner_image[1]->image_url; ?>">
				            </a>
				        
				    </div>
				</figure>
				<figure class="banner-box multi" style="left: 544px">
				    <div class="wrapper">
				        <div class="box-0">
				            
				                <a href="#">
				                    <img style="<?php echo $this->model->get_style($banner_image[2]->image_url);?>" class="front active loaded" src="<?php echo $upload_dir['baseurl'].'/photo-gallery'.$banner_image[2]->image_url; ?>">
				                </a>
				            
				        </div>
				        <div class="box-1">
				            
				                
				                <a href="#">
				                    <img style="<?php echo $this->model->get_style($banner_image[3]->image_url);?>" class="front active loaded" src="<?php echo $upload_dir['baseurl'].'/photo-gallery'.$banner_image[3]->image_url; ?>">
				                </a>
				            
				        </div>
				        <div class="box-2">
				                <a href="#">
				                    <img style="<?php echo $this->model->get_style($banner_image[4]->image_url);?>height:200%" class="front active loaded" src="<?php echo $upload_dir['baseurl'].'/photo-gallery'.$banner_image[4]->image_url; ?>">
				                </a>
				            
				        </div>
				        <div class="bg one"></div>
				        <div class="bg two"></div>
				        <div class="bg three"></div>
				    </div>
				</figure><figure class="banner-box single" style="left: 816px">
				    <div class="wrapper">
				        
				            
				            <a href="/i/npwvbsj">
				                <img style="<?php echo $this->model->get_style($banner_image[5]->image_url);?>" class="back active loaded" src="<?php echo $upload_dir['baseurl'].'/photo-gallery'.$banner_image[5]->image_url; ?>">
				            </a>
				        
				    </div>
				</figure>
				</section>
			        <div class="inner-wrapper">
			            <div style="width:auto;height:auto" class="avatar">
			                    <?php echo get_avatar($user_id , 114 ); ?>
			            </div>
			            <div class="info">
			                <h1><?php echo $user_meta['nickname'][0]; ?></h1>
			                <div class="bio "><?php echo $user_info->user_login; ?></div>
			                
			                    <div class="clearfix location">
			                        <div class="icon"></div>
			                        <div class="name">Chicago, Illinois, United States</div>
			                    </div>
			                
			            </div>
			        </div>
			        <section class="follow-area">
			            <section class="clearfix wrapper">
			                <a class="following" href="<?php echo  get_page_link(167).'&user_name='.$user_name; ?>">
			                    <div class="count"><?php echo $this->model->get_following_count($user_id); ?></div>
			                    <div class="name">ĐANG THEO DÕI</div>
			                </a>
			                <div class="divider"></div>
			                <a class="followers" href="<?php echo get_page_link(164).'&user_name='.$user_name; ?>">
			                    <div class="followers-total count"><?php echo $this->model->get_follower_count($user_id); ?></div>
			                    <div class="name">NGƯỜI THEO DÕI</div>
			                </a>
			            </section>
			        </section>
			    </div>
			    <div class="footer clearfix">
			        <nav style="width: 1060px;">
			            <ul>
			                <li class="images selected">
			                    <a href="<?php echo get_page_link(171).'&user_name='.$user_name.'&content=images'; ?>">ẢNH<span class="thin"><?php echo $this->model->get_image_count($user_id); ?></span></a>
			                    <div class="arrow"></div>
			                </li>
			                <li class="albums ">
			                    <a href="<?php echo get_page_link(150).'&user_name='.$user_name; ?>">ALBUMS <span class="thin"><?php echo $this->model->get_album_count($user_id); ?></span></a>
			                    <div class="arrow"></div>
			                </li>
			                <li class="liked ">
			                    <a href="<?php echo get_page_link(176).'&user_name='.$user_name.'&content=likes'; ?>">THÍCH <span class="thin"><?php echo $this->model->get_like_count($user_id); ?></span></a>
			                    <div class="arrow"></div>
			                </li>
			            </ul>
			            <?php if(is_user_logged_in()&&($current_user->id!=$user_id)) { ?>
	                    <a  class="fading-button follow-button on" id="follow_button" data-following="1" data-force-login="true" data-author-id='<?php echo $user_id; ?>'>
	                        <span id="follow_status_<?php echo $user_id; ?>">
	                        	<?php 
	                        		global $current_user;
		                        	$status=$this->model->user_follow_status($current_user->id,$user_id); 
		                        	echo $status==1 ? "BỎ THEO":"THEO DỎI" ;  
	                        	?>
	                       	</span>
	                    </a>
	                    <?php } ?>
			        </nav>
			    </div>
			</header>

			<?php
		}
		function user_follow()
		{
			$author_id=isset($_POST['author_id']) ? $_POST['author_id']:0;
			global $current_user;
			$status=$this->model->user_follow_status($current_user->id,$author_id);
			echo $status==1 ? "BỎ THEO":"THEO DỎI" ;
		}
		function view_followers_list()
		{
			if(isset($_GET['user_name']))
			{
			 	$user_name=$_GET['user_name'];
				$user_id=$this->model->get_user_id_by_name($user_name);
				$user_meta=get_user_meta($user_id);
				$user_info=$this->model->get_user_info($user_id);
			}
			$upload_dir = wp_upload_dir();
			
			$followers=$this->model->get_followers($user_id);
			global $current_user;
			?>
			<section class="follow-parent">
			    <div class="wrapper" style="width: 1060px;">
			        <div class="clearfix columns">
			            <section class="column left" style="width: 513px;">
			            <?php 
			            	$length=count($followers);
			            	$divider=0;
			            	for($i=0;$i<$length/2;$i++)
							{
								$divider++;
								$user_info=$this->model->get_user_info($followers[$i]->follower_id);
			             ?>
				            <article class="clearfix person">
							    <a class="avatar" href="/user/ToddGilbert">
							        <?php echo get_avatar($followers[$i]->follower_id,70); ?>
							    </a>
							    <div class="info ">
							        <h3 class="profile-link ">
							            <a href="/user/ToddGilbert"><?php echo $user_info->user_login; ?></a>
							        </h3>
							        
							            <div class="location"></div>
							        
							        	<?php if(is_user_logged_in()&&($current_user->id!=$followers[$i]->follower_id)) { ?>
							             <a data-force-login="true" class="fading-button follow-button on" data-following="1" data-author-id='<?php echo $followers[$i]->follower_id; ?>'>
					                        <span id="follow_status_<?php echo $followers[$i]->follower_id; ?>">
					                        	<?php 
					                        		global $current_user;
						                        	$status=$this->model->user_follow_status($current_user->id,$followers[$i]->follower_id); 
						                        	echo $status==1 ? "BỎ THEO":"THEO DỎI" ;  
					                        	?>
					                       	</span>
					                    </a>
					                    <?php } ?>
							    </div>
							    
						        <aside class="clearfix images">
						        <?php 
						        	$followers_image=$this->model->get_user_image($followers[$i]->follower_id,2);
						        	foreach ($followers_image as $follower_image) {
						         		?>
								        <a href="/i/idEuz6Bxj">
								    		<img src="<?php echo $upload_dir['baseurl'].'/photo-gallery/thumb'.$follower_image->image_url; ?>">
										</a>
										<?php 
										} 
								?>
								</aside>
							    
							</article>
							<?php } ?>
							</section>
				            <section class="column right" style="width: 513px;">
				            <?php 
				            	for($i=$divider;$i<$length;$i++)
								{$user_info=$this->model->get_user_info($followers[$i]->follower_id);
					             ?>
						            <article class="clearfix person">
									    <a class="avatar" href="/user/ToddGilbert">
									        <?php echo get_avatar($followers[$i]->follower_id,70); ?>
									    </a>
									    <div class="info ">
									        <h3 class="profile-link ">
									            <a href="/user/ToddGilbert"><?php echo $user_info->user_login; ?></a>
									        </h3>
									        
									            <div class="location"></div>
									        
									        	<?php if(is_user_logged_in()&&($current_user->id!=$followers[$i]->follower_id)) { ?>
									             <a data-force-login="true" class="fading-button follow-button on" data-following="1" data-author-id='<?php echo $followers[$i]->follower_id; ?>'>
							                        <span id="follow_status_<?php echo $followers[$i]->follower_id; ?>">
							                        	<?php 
							                        		global $current_user;
								                        	$status=$this->model->user_follow_status($current_user->id,$followers[$i]->follower_id); 
								                        	echo $status==1 ? "BỎ THEO":"THEO DỎI" ;  
							                        	?>
							                       	</span>
							                    </a>
							                    <?php } ?>
									    </div>
									    
								        <aside class="clearfix images">
								        <?php 
								        	$followers_image=$this->model->get_user_image($followers[$i]->follower_id,2);
								        	foreach ($followers_image as $follower_image) {
								         		?>
										        <a href="/i/idEuz6Bxj">
										    		<img src="<?php echo $upload_dir['baseurl'].'/photo-gallery/thumb'.$follower_image->image_url; ?>">
												</a>
												<?php 
												} 
										?>
										</aside>
									    
									</article>
									<?php } ?>
						</section>
			        </div>
			        <div class="loading">LOADING MORE...</div>
			    </div>
			</section>
    <?php
    		
		}
		function view_following_list()
		{
			if(isset($_GET['user_name']))
			{
			 	$user_name=$_GET['user_name'];
				$user_id=$this->model->get_user_id_by_name($user_name);
				$user_meta=get_user_meta($user_id);
				$user_info=$this->model->get_user_info($user_id);
			}
			$upload_dir = wp_upload_dir();
			
			$authors=$this->model->get_followings($user_id);
			global $current_user;
			?>
			<section class="follow-parent">
			    <div class="wrapper" style="width: 1060px;">
			        <div class="clearfix columns">
			            <section class="column left" style="width: 513px;">
			            <?php 
			            	$length=count($authors);
			            	$divider=0;
			            	for($i=0;$i<$length/2;$i++)
							{
								$divider++;
								$user_info=$this->model->get_user_info($authors[$i]->author_id);
			             ?>
				            <article class="clearfix person">
							    <a class="avatar" href="/user/ToddGilbert">
							        <?php echo get_avatar($authors[$i]->author_id,70); ?>
							    </a>
							    <div class="info ">
							        <h3 class="profile-link ">
							            <a href="/user/ToddGilbert"><?php echo $user_info->user_login; ?></a>
							        </h3>
							        
							            <div class="location"></div>
							        
							        	<?php if(is_user_logged_in()&&($current_user->id!=$authors[$i]->follower_id)) { ?>
							             <a data-force-login="true" class="fading-button follow-button on" data-following="1" data-author-id='<?php echo $authors[$i]->author_id; ?>'>
					                        <span id="follow_status_<?php echo $followers[$i]->follower_id; ?>">
					                        	<?php 
					                        		global $current_user;
						                        	$status=$this->model->user_follow_status($current_user->id,$authors[$i]->author_id); 
						                        	echo $status==1 ? "BỎ THEO":"THEO DỎI" ;  
					                        	?>
					                       	</span>
					                    </a>
					                    <?php } ?>
							    </div>
							    
						        <aside class="clearfix images">
						        <?php 
						        	$authors_image=$this->model->get_user_image($authors[$i]->author_id,2);
						        	foreach ($authors_image as $author_image) {
						         		?>
								        <a href="/i/idEuz6Bxj">
								    		<img src="<?php echo $upload_dir['baseurl'].'/photo-gallery/thumb'.$author_image->image_url; ?>">
										</a>
										<?php 
										} 
								?>
								</aside>
							    
							</article>
							<?php } ?>
							</section>
				            <section class="column right" style="width: 513px;">
				            <?php 
				            	for($i=$divider;$i<$length;$i++)
								{$user_info=$this->model->get_user_info($authors[$i]->author_id);
					             ?>
						            <article class="clearfix person">
									    <a class="avatar" href="/user/ToddGilbert">
									        <?php echo get_avatar($authors[$i]->author_id,70); ?>
									    </a>
									    <div class="info ">
									        <h3 class="profile-link ">
									            <a href="/user/ToddGilbert"><?php echo $user_info->user_login; ?></a>
									        </h3>
									        
									            <div class="location"></div>
									        
									        	<?php if(is_user_logged_in()&&($current_user->id!=$authors[$i]->author_id)) { ?>
									             <a data-force-login="true" class="fading-button follow-button on" data-following="1" data-author-id='<?php echo $followers[$i]->follower_id; ?>'>
							                        <span id="follow_status_<?php echo $followers[$i]->follower_id; ?>">
							                        	<?php 
							                        		global $current_user;
								                        	$status=$this->model->user_follow_status($current_user->id,$authors[$i]->author_id); 
								                        	echo $status==1 ? "BỎ THEO":"THEO DỎI" ;  
							                        	?>
							                       	</span>
							                    </a>
							                    <?php } ?>
									    </div>
									    
								        <aside class="clearfix images">
								        <?php 
								        	$authors_image=$this->model->get_user_image($authors[$i]->author_id,2);
								        	foreach ($authors_image as $author_image) {
								         		?>
										        <a href="/i/idEuz6Bxj">
										    		<img src="<?php echo $upload_dir['baseurl'].'/photo-gallery/thumb'.$author_image->image_url; ?>">
												</a>
												<?php 
												} 
										?>
										</aside>
									    
									</article>
									<?php } ?>
						</section>
			        </div>
			        <div class="loading">LOADING MORE...</div>
			    </div>
			</section>
    <?php
    		
		}
	}
?>